package com.ruoyi.web.controller.mk;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.mk.domain.MkConfiguration;
import com.ruoyi.mk.service.IMkConfigurationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 配置下行Controller
 * 
 * @author guan
 * @date 2021-12-09
 */
@RestController
@RequestMapping("/mk/configuration")
public class MkConfigurationController extends BaseController
{
    @Autowired
    private IMkConfigurationService mkConfigurationService;

    /**
     * 查询配置下行列表
     */
    @PreAuthorize("@ss.hasPermi('mk:configuration:list')")
    @GetMapping("/list")
    public TableDataInfo list(MkConfiguration mkConfiguration)
    {
        startPage();
        List<MkConfiguration> list = mkConfigurationService.selectMkConfigurationList(mkConfiguration);
        return getDataTable(list);
    }

    /**
     * 导出配置下行列表
     */
    @PreAuthorize("@ss.hasPermi('mk:configuration:export')")
    @Log(title = "配置下行", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MkConfiguration mkConfiguration)
    {
        List<MkConfiguration> list = mkConfigurationService.selectMkConfigurationList(mkConfiguration);
        ExcelUtil<MkConfiguration> util = new ExcelUtil<MkConfiguration>(MkConfiguration.class);
        return util.exportExcel(list, "配置下行数据");
    }

    /**
     * 获取配置下行详细信息
     */
    @PreAuthorize("@ss.hasPermi('mk:configuration:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(mkConfigurationService.selectMkConfigurationById(id));
    }

    /**
     * 新增配置下行
     */
    @PreAuthorize("@ss.hasPermi('mk:configuration:add')")
    @Log(title = "配置下行", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MkConfiguration mkConfiguration)
    {
        return toAjax(mkConfigurationService.insertMkConfiguration(mkConfiguration));
    }

    /**
     * 修改配置下行
     */
    @PreAuthorize("@ss.hasPermi('mk:configuration:edit')")
    @Log(title = "配置下行", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MkConfiguration mkConfiguration)
    {
        return toAjax(mkConfigurationService.updateMkConfiguration(mkConfiguration));
    }

    /**
     * 删除配置下行
     */
    @PreAuthorize("@ss.hasPermi('mk:configuration:remove')")
    @Log(title = "配置下行", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(mkConfigurationService.deleteMkConfigurationByIds(ids));
    }
}
